﻿@using Abp.Collections.Extensions
@using Abp0713Demo.Web.Views
@model Abp0713Demo.Web.Models.Layout.TopMenuViewModel
@{
    var calculateMenuUrl = new Func<string, string>((url) =>
    {
        if (string.IsNullOrEmpty(url))
        {
            return ApplicationPath;
        }

        if (UrlChecker.IsRooted(url))
        {
            return url;
        }

        return ApplicationPath + url;
    });
}
@foreach (var menuItem in Model.MainMenu.Items)
{
    
    <li class="@(Model.ActiveMenuItemName == menuItem.Name ? "active" : "")">
        @if (menuItem.Items.IsNullOrEmpty())
        {
            <a href="@calculateMenuUrl(menuItem.Url)">
                @if (!string.IsNullOrWhiteSpace(menuItem.Icon))
                {
                    <i class="@menuItem.Icon"></i>
                }
                <span class="nav-label">@menuItem.DisplayName</span>
            </a>
        }
        else
        {
            <a href="">
                @if (!string.IsNullOrWhiteSpace(menuItem.Icon))
                {
                    <i class="@menuItem.Icon"></i>
                }
                <span class="nav-label">@menuItem.DisplayName</span>
                <span class="fa arrow"></span>
            </a>
            <ul class="nav nav-second-level">
                @foreach (var subMenuItem in menuItem.Items)
                {
                    <li>
                        <a class="J_menuItem" href="@calculateMenuUrl(subMenuItem.Url)">
                            @if (!string.IsNullOrWhiteSpace(subMenuItem.Icon))
                            {
                                <i class="@subMenuItem.Icon"></i>
                            }
                            @subMenuItem.DisplayName
                        </a>
                    </li>
                }
            </ul>
        }
    </li>
}